import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/login/login.vue'
Vue.use(VueRouter)
    //重写vueRouter的push方法，让点击重复路由的情况不会报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
const routes = [{
    path: '/login',
    name: 'login',
    component: Login
}, {
    path: '/',
    name: 'Home',
    component: Home,
    children: [{
            path: '/index',
            name: 'index',
            component: () =>
                import ('../views/main/compoents/index.vue')
        }, {
            path: '/userlist',
            name: 'userlist',
            component: () =>
                import ('../views/main/compoents/userlist/index.vue')
        }, {
            path: '/usersetting',
            name: 'usersetting',
            component: () =>
                import ('../views/main/compoents/userSetting/index.vue')
        }, {
            path: '/adminlist',
            name: 'adminlist',
            component: () =>
                import ('../views/main/compoents/adminList/index.vue')
        }, {
            path: '/allinfo',
            name: 'allinfo',
            component: () =>
                import ('../views/main/compoents/record/addInfo/allInfo.vue')
        }, {
            path: '/infoexamine',
            name: 'infoexamine',
            component: () =>
                import ('../views/main/compoents/record/infoExamine.vue')
        },
        {
            path: '/helper',
            name: 'helper',
            component: () =>
                import ('../views/main/compoents/helper.vue')
        }
    ]
}, ]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router